package com.swyc.osschat.Common.Result;

/**
 * 响应结果生成工厂类
 * @param <T>
 */
public class ResultFactory<T> {
    public static <T> Result<T> buildSaveOrUpdateResult(boolean operateResult){
        if (operateResult){
            return buildSuccessResult(null);
        }else {
            return buildFailResult("操作失败！");
        }
    }
    public static <T> Result<T> buildSuccessResult(T data){
        return buildResult(ResultStatus.SUCCESS,"成功",data);
    }
    public static <T> Result<T> buildFailResult(String message) {
        return buildResult(ResultStatus.FAIL, message, null);
    }

    public static <T> Result<T> buildResult(ResultStatus resultStatus, String message, T data) {
        return buildResult(resultStatus.status, message, data);
    }
    public static <T> Result<T> buildResult(int resultStatus, String message, T data){
        return new Result<T>(resultStatus,message,data);
    }
}
